const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')

let config = {
  mode: 'development',
  devtool: 'cheap-eval-source-map',
  entry: './src/index.js',
  output: {
    path: path.resolve(__dirname, 'release'),
    filename: '[name].js'
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /(node_modules|bower_components)/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env'],
            plugins: [
              ['@babel/plugin-proposal-decorators', {legacy: true}],
              ['@babel/plugin-proposal-class-properties'],
            ]
          }
        }
      }
    ]
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: './index.html'
    })
  ],
  devServer: {
    contentBase: './',
    open: true,
    port: 9000,
    // 代理配置
    proxy: {
      '/api/*': {
        target: 'http://localhost:8880'
      }
    }
  }
}

module.exports = config